extends TextureButton

var is_dragging = false

func _ready():
	set_process_input(true)

func _gui_input(event):
	if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
		if event.pressed :
				is_dragging = true
				$"..".modulate = Color(2, 2, 2, 1)
				grab_focus()  # 抓取焦点，以防止其他控件捕获鼠标事件
		else:
			if is_dragging:
				is_dragging = false
				$"..".modulate = Color(1, 1, 1, 1)
				release_focus()
				# 处理放下逻辑，这里可以执行您需要的操作

func _process(delta):
	if is_dragging:
		var global_mouse_pos = get_global_mouse_position()
		$"..".global_position = global_mouse_pos

